package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cleaningcloud.cld.domain.dto.CldCheckPerformanceDto;
import com.cleaningcloud.cld.domain.vo.CldCheckPerformanceVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldCheckPerformance;
import com.cleaningcloud.cld.service.ICldCheckPerformanceService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 绩效考核Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-12
 */
@RestController
@RequestMapping("/checkPerformance")
public class CldCheckPerformanceController extends BaseController
{
    @Autowired
    private ICldCheckPerformanceService cldCheckPerformanceService;

    /**
     * 查询绩效考核列表
     */
    @RequiresPermissions("cld:checkPerformance:list")
    @GetMapping("/list")
    public TableDataInfo list(CldCheckPerformance cldCheckPerformance)
    {
        startPage();
        List<CldCheckPerformanceVo> list = cldCheckPerformanceService.selectCldCheckPerformanceList(cldCheckPerformance);
        return getDataTable(list);
    }

    /**
     * 导出绩效考核列表
     */
    @RequiresPermissions("cld:checkPerformance:export")
    @Log(title = "绩效考核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldCheckPerformance cldCheckPerformance)
    {
        List<CldCheckPerformanceVo> list = cldCheckPerformanceService.selectCldCheckPerformanceList(cldCheckPerformance);
        ExcelUtil<CldCheckPerformanceVo> util = new ExcelUtil<>(CldCheckPerformanceVo.class);
        util.exportExcel(response, list, "绩效考核数据");
    }

    /**
     * 获取绩效考核详细信息
     */
    @RequiresPermissions("cld:checkPerformance:query")
    @GetMapping(value = "/{performanceId}")
    public AjaxResult getInfo(@PathVariable("performanceId") Long performanceId)
    {
        return success(cldCheckPerformanceService.selectCldCheckPerformanceByPerformanceId(performanceId));
    }

    /**
     * 新增绩效考核
     */
    @RequiresPermissions("cld:checkPerformance:add")
    @Log(title = "绩效考核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldCheckPerformanceDto cldCheckPerformanceDto)
    {
        return toAjax(cldCheckPerformanceService.insertCldCheckPerformance(cldCheckPerformanceDto));
    }

    /**
     * 修改绩效考核
     */
    @RequiresPermissions("cld:checkPerformance:edit")
    @Log(title = "绩效考核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldCheckPerformanceDto cldCheckPerformanceDto)
    {
        return toAjax(cldCheckPerformanceService.updateCldCheckPerformance(cldCheckPerformanceDto));
    }

    /**
     * 删除绩效考核
     */
    @RequiresPermissions("cld:checkPerformance:remove")
    @Log(title = "绩效考核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{performanceIds}")
    public AjaxResult remove(@PathVariable Long[] performanceIds)
    {
        return toAjax(cldCheckPerformanceService.deleteCldCheckPerformanceByPerformanceIds(performanceIds));
    }
}
